home *** CD-ROM | disk | FTP | other *** search
- Path: crchh327.rich.bnr.ca!karlon
- From: karlon@bnr.ca (Karlon West)
- Newsgroups: comp.lang.c
- Subject: Re: Problem with ascii to number conversion.
- Date: 21 Jan 1996 19:43:45 GMT
- Organization: Bell-Northern Research, Richardson, TX
- Distribution: world
- Message-ID: <4du51h$dc0@crchh327.rich.bnr.ca>
- References: <96012012081730705@busilink.com> <20JAN199609563071@erich.triumf.ca>
- NNTP-Posting-Host: crchhdaa.rich.bnr.ca
- X-Newsreader: TIN [version 1.2 PL2]
-
- P.Bennett (bennett@erich.triumf.ca) wrote:
- > In article <96012012081730705@busilink.com>, paul.kelley@busilink.com (Paul Kelley) writes...
- > >Hi,
- > > i am a beginner c programmer, stuck on what i thought was a simple
- > >problem. I have an ascii input file that contains payroll info for a
- > >month, the data is monetary values as ascii strings. I am trying to
- > >convert the ascii ti numbers total the result then place in another
- > >file. I am using micrsoft quick C and the ascii to number functions in
- > >it. Apparenntly these functions only work correctly up to four digits.
- > >After that teh ouput goes wild.
-
- > A widely used commercial product like Micro$oft, unlikely to have this sort of
- > a bug, so it is probably your program. The problem would be easier to resolve
- > if you had showed some source code.
-
- > However, "4 digits" sounds suspiciously like the size of a pointer in some
- > memory models...
-
- I'd guess that he's hitting the 16 bit bounds on IBM's ints. It works
- great from 0 up to 9999, but with five or more digits, you start wrapping
- at 32767. So, Paul, instead of using atoi(), use strtol().
-